﻿using Common.Service;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using RabitPart.ReadApi.Application.Loginfile;
using RabitPart.ReadApi.Application.TraceabilityFile;
using RabitPart.ReadApi.Utils;

namespace RabitPart.ReadApi.Controllers
{  /// <summary>
   /// 控制器--读api溯源管理
   /// </summary>
    [Route("api/[controller]/[action]")]

    [ApiController] 
    public class TraceabilityCreadePartController : ControllerBase
    {
        private readonly IMediator mediator;
        private readonly ILogger<TraceabilityCreadePartController> logger; 

        public TraceabilityCreadePartController(IMediator mediator, ILogger<TraceabilityCreadePartController> logger, SmsClientFactory _smsClientFactory)
        {
            this.mediator = mediator;
            this.logger = logger; 
        }

        /// <summary>
        /// 溯源管理显示
        /// </summary>
        /// <param name="pageindex">当前页</param>
        /// <param name="pagesize">页容量</param>
        /// <returns>溯源管理显示</returns>
        [HttpGet] 
        public async Task<ApiResult<APIPagingresult<IList<TraceabilityShowCommanResponstity>>>> GetLogin(int pageindex, int pagesize)
        {
            try
            {
                TraceabilityShowComman model = new TraceabilityShowComman();
                model.pageindex = pageindex;
                model.pagesize = pagesize;
                return await mediator.Send(model);
            }
            catch (Exception ex)
            {
                logger.LogError("溯源管理显示失败" + ex.Message);
                throw;
            }
        }

    }//
}
